/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 				</p>
 * <p>		    All right reserved. 		     		</p>
 * <p>项目名称 ：深圳公路信息资源整合及国省检日常化监管管理        				</p>
 * <p>创建者 ：詹春贤 										</p>
 * <p>描   述  ：路政管理 - 路产保护 - 公路监管巡查 						</p>
 * <p>最后修改 ：$: 2017年9月7日-下午5:56:50 v 1.0.0	 Administrator   $   </p>
 * 
*/

package com.pengtu.gsj.controller.lzgl;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pengtu.gsj.controller.base.DefaultBaseController;
import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.entity.lzgl.RoadSupInNote;
import com.pengtu.gsj.interceptor.Token;
import com.pengtu.gsj.service.lzgl.RoadSupInNoteService;
import com.pengtu.gsj.utils.web.SpringMvcUtils;

/**
 * 
 * RoadSupInNoteController
 * 
 * 2017年9月7日 下午5:56:50
 * 
 * @version 1.0.0
 * 
 */

@Controller
@RequestMapping("roadSupInNote")
public class RoadSupInNoteController extends DefaultBaseController{

	@Autowired
	private RoadSupInNoteService roadSupInNoteService;

	/**
	 * 加载
	 * @param id
	 * @return
	 */
	@ModelAttribute
	public RoadSupInNote load(String id){
		RoadSupInNote roadSupInNote;
		if(StringUtils.isNotEmpty(id)){
			roadSupInNote = roadSupInNoteService.getRoadSupInNoteById(id);
		}else{
			roadSupInNote = new RoadSupInNote();
		}
		return roadSupInNote;
	}
	
	
	/**
	 * 页面跳转
	 * @return
	 */
	@Token(save = true)
	@RequestMapping("listInfo")
	public String showLisfInfo() {
		return "lzgl/roadSupInNote_list";
	}
	
	
	@ResponseBody
	@RequestMapping(value="list", produces = "application/json; charset=utf-8")
	public Page<RoadSupInNote> getRoadSupInNoteList(Page<RoadSupInNote> page, HttpServletRequest request){
		QueryFilter queryFilter = QueryFilter.buildFromHttpRequest(request);
		if (!page.isOrderBySetted()) {
			page.setOrderBy("year");
			page.setOrder(Page.ASC);
		}
		page = roadSupInNoteService.findRoadSupInNote(page,queryFilter);
		return page;
	}
	
	/**
	 * saveRoadSupInNote:
	 * 适用: 保存公路监督巡查的数据
	 * @param roadSupInNote
	 * @return 
	 * @exception 
	 * @since  1.0.0
	*/
	@ResponseBody
	@Token(remove = true)
	@RequestMapping(value = "save", method=RequestMethod.POST)
	public boolean saveRoadSupInNote(@ModelAttribute RoadSupInNote roadSupInNote){
		roadSupInNoteService.saveRoadSupInNote(roadSupInNote);
		return true;
	}
	
	
	/**
	 * showEmergDRoadSupInNote 适用: 展示公路监督巡查页面
	 * @param roadSupInNote
	 * @return 
	 * @exception 
	 * @since  1.0.0
	*/
	@ResponseBody    
	@RequestMapping(value="show")
	public RoadSupInNote showRoadSupInNote (@ModelAttribute RoadSupInNote roadSupInNote){
		return roadSupInNote;
	}
	
	/**
	 * delateInfoManagement:
	 * 适用: 删除公路监督巡查的数据
	 * @param roadSupInNote
	 * @return 
	 * @exception 
	 * @since  1.0.0
	*/
	@ResponseBody
	@RequestMapping(value="delete")
	public boolean delateInfoManagement(@ModelAttribute RoadSupInNote roadSupInNote){
		roadSupInNoteService.delateRoadSupInNote(roadSupInNote);
		return true;
	}
	
	 /**
	  * 
	  * checkYearOrg:
	  * 适用:新增和修改公路监督巡查时，ajax判断 年份+基层执法所  在数据库中是否已经存在
	  * @return  返回true或false  json数据
	  * @exception 
	  * @since  1.0.0
	  */
	@ResponseBody
	@RequestMapping(value = "checkYearOrg", produces = "application/json; charset=utf-8")
	public Boolean checkYearOrg() {
		String year = SpringMvcUtils.getParameter("year");
		String signOrg = SpringMvcUtils.getParameter("signOrg");
		String id = SpringMvcUtils.getParameter("id");
		return roadSupInNoteService.checkYearOrg(year, signOrg, id);
	}
}
